import {
     getDepartmentStaffData
} from '@/api/human/staff'

const state =  {
    staffData: [],
}
const mutations = {
    GET_STAFF_DATA: (state, data) => {
      state.staffData = data
    },
  }
const actions = {
    getOrgIdPepartmentStaff({ commit },orgId) {
        return new Promise((resolve, reject) => {
            getDepartmentStaffData(orgId).then(res => {
                if (res.code === '1') {
                    let array = JSON.parse(JSON.stringify(res.data).replace(/staffId/g, 'value').replace(/name/g, 'label'));
                    commit('GET_STAFF_DATA', array)
                    resolve();
                }
            }).catch(error => {
                reject(error)
            })
        })
    },
}
export default {
  namespaced: true,
    actions,
    state,
  mutations
}
